﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Imagiality.MeshProcessing
{
    public class ByTypeSceneQuery<T> : SceneQuery<T> where T: SceneObject
    {
        public ByTypeSceneQuery() : base()
        {
        }

        public ByTypeSceneQuery(SceneQuery<T> innerQuery)
            : base(innerQuery)
        { 
        
        }

        public ByTypeSceneQuery(SceneQuery<T> innerQuery, int depthLimit)
            : base(innerQuery, depthLimit)
        { }

        public ByTypeSceneQuery(int depthLimit)
            : base(depthLimit)
        { }
        protected override bool IsMatch(SceneObject obj)
        {
            Type clazz = typeof(T);

            if (obj.GetType().Equals(clazz) || obj.GetType().IsSubclassOf(clazz) || clazz.IsAssignableFrom(obj.GetType()))
                return true;

            return false;
        }

        protected override bool ProcessNextLevel(int level, SceneObject parent)
        {
            return true;
        }
    }
}
